//
// Created by mio on 25-5-12.
//

#ifndef AUDIOCAPTURE_H
#define AUDIOCAPTURE_H

#include <thread>
#include <cstdint>
#include <memory>

class AudioBuffer;
class WASAPICapture;

class AudioCapture
{
public:
    AudioCapture();
    ~AudioCapture();

public:
    bool Init(uint32_t size = 20480);
    void Close();
    int GetSamples();
    int Read(uint8_t* data, uint32_t samples);

    inline bool CapturStarted() const {}
    inline uint32_t GetChannels() const { return channels_; }
    inline uint32_t GetSampleRate() const { return sampleRate_; }
    inline uint32_t GetBitsPerSample() const { return bits_per_samples_; }

private:
    int StartCapture();
    int StopCapture();

private:
    bool isInitialized_ = false;
    bool isStarted_ = false;
    uint32_t channels_ = 2;
    uint32_t sampleRate_ = 48000;
    uint32_t bits_per_samples_ = 16;
    std::unique_ptr<WASAPICapture> capture_;
    std::unique_ptr<AudioBuffer> audio_buffer_;

};



#endif //AUDIOCAPTURE_H
